import { defineConfig, type DefaultTheme } from "vitepress";

export const zh = defineConfig({
  lang: "zh-Hans",
  description: "基于种子特征码的交叉索引工具.",
  themeConfig: {
    nav: nav(),

    sidebar: {
      "/guide/": { base: "/guide/", items: sidebarGuide() },
      "/reference/": { base: "/reference/", items: sidebarReference() },
    },

    editLink: {
      pattern: "https://github.com/ledccn/iyuuplus-dev/edit/main/docs/:path",
      text: "在 GitHub 上编辑此页面",
    },

    footer: {
      message: "基于 MIT 许可发布",
      copyright: `版权所有 © 2017-${new Date().getFullYear()} www.iyuu.cn <a href="https://beian.miit.gov.cn" rel="noreferrer" target="_blank">琼ICP备2024017379号-2</a>`,
    },

    docFooter: {
      prev: "上一页",
      next: "下一页",
    },

    outline: {
      label: "页面导航",
    },

    lastUpdated: {
      text: "最后更新于",
      formatOptions: {
        dateStyle: "short",
        timeStyle: "medium",
      },
    },

    langMenuLabel: "多语言",
    returnToTopLabel: "回到顶部",
    sidebarMenuLabel: "菜单",
    darkModeSwitchLabel: "主题",
    lightModeSwitchTitle: "切换到浅色模式",
    darkModeSwitchTitle: "切换到深色模式",
  },
});

function nav(): DefaultTheme.NavItem[] {
  return [
    {
      text: "使用指南",
      link: "/guide/what-is-iyuu",
      activeMatch: "/guide/",
    },
    {
      text: "开发参考",
      link: "/reference/site_list",
      activeMatch: "/reference/",
    },
    {
      text: "项目仓库",
      items: [
        {
          text: "gitee",
          link: "https://gitee.com/ledc/iyuuplus-dev",
        },
        {
          text: "github",
          link: "https://github.com/ledccn/iyuuplus-dev",
        },
        {
          text: "DockerHub",
          link: "https://hub.docker.com/r/iyuucn/iyuuplus",
        },
        {
          text: "IYUU浏览器助手",
          link: "https://gitee.com/ledc/iyuu-helper",
        },
        {
          text: "文档源码",
          link: "https://gitee.com/ledc/iyuu-docs",
        },
      ],
    },
    {
      text: "爱语飞飞",
      link: "https://iyuu.cn",
    },
    {
      text: "Telegram频道",
      link: "https://t.me/iyuucn",
    },
    {
      text: "博客",
      link: "https://www.iyuu.cn",
    },
  ];
}

function sidebarGuide(): DefaultTheme.SidebarItem[] {
  return [
    {
      text: "简介",
      collapsed: false,
      items: [
        { text: "什么是 IYUU", link: "what-is-iyuu" },
        { text: "快速开始", link: "getting-started" },
        { text: "远程安装服务", link: "paid-service" },
        { text: "Docker镜像", link: "docker-image" },
      ],
    },
    {
      text: "安装",
      collapsed: false,
      items: [
        { text: "Docker Cli", link: "install-docker-cli" },
        { text: "Docker Compose", link: "install-docker-compose" },
        { text: "Arch Linux", link: "install-archlinux" },
        { text: "Linux", link: "install-linux" },
        { text: "Windows 源码", link: "install-windows-source" },
        { text: "Windows 客户端", link: "install-windows" },
        { text: "MacOS", link: "install-macos" },
        { text: "unRaid", link: "install-unraid" },
        { text: "Termux", link: "install-termux" },
        { text: "群晖", link: "install-synology" },
        { text: "绿联", link: "install-ugreen" },
        { text: "威联通", link: "install-qnap" },
        { text: "极空间", link: "install-zspace" },
        { text: "铁威马", link: "install-tos" },
        { text: "宝塔面板", link: "install-bt" },
        { text: "1Panel面板", link: "install-1panel" },
        { text: "飞牛OS", link: "install-fnnas" },
      ],
    },
    {
      text: "使用",
      collapsed: false,
      items: [
        { text: "下载器", link: "downloader" },
        { text: "站点", link: "site" },
        { text: "通知渠道", link: "notification" },
        { text: "数据目录", link: "data-directory" },
        { text: "计划任务", link: "cron" },
        { text: "自动辅种", link: "reseed-torrent" },
        { text: "自动转移", link: "transfer-torrent" },
        { text: "环球影视", link: "hilx" },
        { text: "动态口令", link: "totp" },
      ],
    },
    {
      text: "问答",
      collapsed: false,
      items: [
        { text: "常见问题", link: "qa-iyuuplus" },
        { text: "辅种问题", link: "qa-reseed" },
        { text: "其他问题", link: "qa-others" },
        { text: "如何更新或迁移", link: "qa-iyuuplus-update" },
        { text: "意见建议及BUG反馈", link: "qa-bug" },
      ],
    },
    { text: "二次开发和 API 参考", base: "/reference/", link: "site_list" },
  ];
}

function sidebarReference(): DefaultTheme.SidebarItem[] {
  return [
    {
      text: "开发参考",
      items: [
        { text: "新增站点", link: "new_site" },
        { text: "推荐站点", link: "recommend" },
        {
          text: "扫码登录",
          base: "/reference/scan-qrcode-",
          items: [
            { text: "非对称RSA(公钥验签)", link: "rsa" },
            { text: "对称AES(对称密钥)", link: "aes" },
          ],
        },
      ],
    },
    {
      text: "开放API",
      collapsed: false,
      items: [
        { text: "全部站点", link: "site_list" },
        { text: "推荐站点", link: "site_recommend" },
        { text: "汇报辅种站点", link: "site_report_existing" },
        { text: "查询辅种", link: "reseed_index" },
        { text: "绑定站点激活token", link: "users_bind" },
      ],
    },
    {
      text: "应用API",
      collapsed: false,
      items: [
        { text: "种子收录数", link: "spider_site_total" },
        { text: "种子辅种数据", link: "spider_reseed_index" },
        { text: "扫码登录", link: "third_login_scene" },
      ],
    },
  ];
}

export const search: DefaultTheme.AlgoliaSearchOptions["locales"] = {
  root: {
    placeholder: "搜索文档",
    translations: {
      button: {
        buttonText: "搜索文档",
        buttonAriaLabel: "搜索文档",
      },
      modal: {
        searchBox: {
          resetButtonTitle: "清除查询条件",
          resetButtonAriaLabel: "清除查询条件",
          cancelButtonText: "取消",
          cancelButtonAriaLabel: "取消",
        },
        startScreen: {
          recentSearchesTitle: "搜索历史",
          noRecentSearchesText: "没有搜索历史",
          saveRecentSearchButtonTitle: "保存至搜索历史",
          removeRecentSearchButtonTitle: "从搜索历史中移除",
          favoriteSearchesTitle: "收藏",
          removeFavoriteSearchButtonTitle: "从收藏中移除",
        },
        errorScreen: {
          titleText: "无法获取结果",
          helpText: "你可能需要检查你的网络连接",
        },
        footer: {
          selectText: "选择",
          navigateText: "切换",
          closeText: "关闭",
          searchByText: "搜索提供者",
        },
        noResultsScreen: {
          noResultsText: "无法找到相关结果",
          suggestedQueryText: "你可以尝试查询",
          reportMissingResultsText: "你认为该查询应该有结果？",
          reportMissingResultsLinkText: "点击反馈",
        },
      },
    },
  },
};
